package com.jiang.专题.矩阵.Q48;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/08/27 10:05
 */
class Solution {
    public void rotate(int[][] matrix) {
        int m = matrix.length;
        // 对角线翻转
        for (int i = 0; i < m; i++) {
            for(int j = 0; j < i; j++) {
                int temp = matrix[i][j];
                matrix[i][j] = matrix[j][i];
                matrix[j][i] = temp;
            }
        }

        // 行翻转
        for (int[] row: matrix) {
            for (int i = 0; i < m / 2; i++) {
                int temp = row[i];
                row[i] = row[m - i - 1];
                row[m - i - 1] = temp;
            }
        }
    }
}